Skip to content

Support nested skill discovery in skills directories - #1801

Open
YrFnS wants to merge 1 commit into
CodebuffAI:mainfrom
YrFnS:feat/nested-skills-discovery
Open

YrFnS wants to merge 1 commit into
CodebuffAI:mainfrom
YrFnS:feat/nested-skills-discovery

Conversation

@YrFnS

@YrFnS YrFnS commented Dec 4, 2026

Copy link
Copy Markdown

Fixes #1784.

Skills can now be organized in category/organizational subdirectories under a skills root. Discovery walks the tree (bounded depth) and treats any directory containing a SKILL.md as a skill; the skill's identity comes from the directory that contains SKILL.md, not its parent category folders (which are purely organizational). Category folders need not match the skill-name regex.

  • sdk/src/skills/load-skills.ts: recursive discovery with bounded depth, skipping hidden/heavy dirs; skill dirs are not descended into.
  • packages/agent-runtime/src/tools/handlers/tool/skill.ts: mid-session disk lookup now searches nested category folders too.

Tests: existing load-skills and skill handler tests pass (pre-existing platform failures unchanged).

@codebuff-team

Copy link
Copy Markdown
Contributor

Good instinct and the core logic (bounded-depth recursive walk, skip hidden/heavy dirs, identity from the SKILL.md-containing dir) is sound and matches the issue's intent. A few things to tighten before this is port-ready:

  1. No new tests. This repo's existing load-skills tests presumably cover flat discovery; a nested-skill feature needs new test cases (nested category dirs, name collisions between nested skills, depth-limit behavior, hidden-dir skipping) in both sdk/src/skills/load-skills.test.ts and the skill handler tests. "Existing tests pass" isn't evidence the new code path works.

  2. Silent name collisions. discoverSkillsFromDirectory merges nested results with Object.assign(skills, nested) — if two skills in different category folders share a name, one silently overwrites the other with no warning. Given identity is now decoupled from the full path, this seems likely to happen and deserves at least a verbose warning, matching existing behavior for invalid names.

  3. skill.ts recursive lookup is O(n) full-tree walk per mid-session lookup, done via readdirSync/statSync on every call — for large skills directories this could be slow compared to the old direct path.join + stat. Worth a comment on expected scale, or caching.

  4. Duplicate MAX_SKILL_NESTING_DEPTH/depth > 6 magic number logic exists in both files independently (skill.ts hardcodes 6 inline vs. the named constant in load-skills.ts) — consider sharing the constant to avoid drift.

Not close-worthy, the direction is right, but needs tests and the collision-handling question answered before a maintainer should port it.

@codebuff-team codebuff-team added bot:triaged Classified by the community triage bot pr:needs-work Right idea, not mergeable as written labels Dec 4, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:triaged Classified by the community triage bot pr:needs-work Right idea, not mergeable as written

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nested skills discovery

2 participants